<?php
  header("Content-type:application/json");
  include("../conn/conn.php");
  
  $json=file_get_contents("php://input");
  $arr=json_decode($json,true);
  $code =$arr['code'];
  $sql1="SELECT cl from grad_user where code='$code'";
  $r1=mysqli_query($link,$sql1);
  if(mysqli_num_rows($r1)>0){
      $row=mysqli_fetch_assoc($r1);
      $cl= $row['cl'];
  }else{
      $res=array(
        'code' =>201,
        'msg'=>'获取列表失败'

      );
  }
  $sql2="SELECT * from grad_course where `type`=$cl";
  $r2=mysqli_query($link,$sql2);
  $aArr=[];
  foreach($r2 as $row2){
      $aArr[] =array(
         'id'=>$row2['id'],
         'title'=>$row2['title'],
         'teacher'=>$row2['teacher'],
         'desc'=>$row2['desc'],
         'cits'=>$row2['cits'],
         'nums'=>$row2['nums']
      ); 
  }
  echo json_encode($aArr,true);
  

 
  

